from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlite3 import dbapi2 as sqlite

DATABASE_URL = "sqlite:///./movie_chat.db"
# DATABASE_URL = "sqlite:///C:/shixi/langserve_yangyuran/app/movie_chat.db"

engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False}, module=sqlite)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)


def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()
